<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>天禾人才</title>
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="minimal-ui=yes,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<meta name="msapplication-tap-highlight" content="no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        function submit(){
            $.ajax({
                type: 'POST',
                url: '/wechatPay/jsOarder',
                data: {'detail':'测试1','desc':'测试1','goodSn':'20000000102','orderSn':'200000001112','amount':'0.02'},
                success: function(data){
	                console.log(data.obj);
	                var appId=data.obj.appId;
	                var timeStamp=data.obj.timeStamp;
	                var nonceStr=data.obj.nonceStr;
	                var packages=data.obj.package;
	                var paySign=data.obj.paySign;
	                WeixinJSBridge.invoke(
	                        'getBrandWCPayRequest', {
	                            "appId":appId,                 //公众号名称，由商户传入
	                            "timeStamp":timeStamp,         //时间戳，自1970年以来的秒数
	                            "nonceStr":nonceStr,           //随机串
	                            "package":packages,
	                            "signType":"MD5",              //微信签名方式：
	                            "paySign":paySign              //微信签名
	                        },
	                        function(res){
	                            WeixinJSBridge.log(res.err_msg);
	                            if(res.err_msg == "get_brand_wcpay_request:ok"){
	                                alert("成功");
	                            }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
	                                alert("取消");
	                            }else{
	                                alert("失败");
	                            }
	                        }
	                );
            } ,
                dataType: "json"});

        }

        $(function(){
                $("#sub").click(function(){
                    submit();
                });
        });

    </script>
</head>
<body>
<input type="text" placeholder="请输入金额"/><br>
<input type="button" id="sub" value="提交">
</body>
</html>
